import java.io.File;


public class PathResolver {
	public static String getCurrentLocalDataPath(String uri, String root, String relativePath)
	{
		return root;
	}
	public static String getInfoURI(String uri, String relativePath)
	{
		return uri + ".LS-INFO/" + relativePath.replace('/', '~');
	}
	public static String getFileURI(String uri, String relativePath)
	{
		if(uri.endsWith("/") && relativePath.startsWith("/"))
			relativePath = relativePath.substring(1, relativePath.length());
		return uri + relativePath;
	}
	public static String formalizeURI(String uri)
	{
		if((!uri.endsWith("/")))
			uri += "/";
		return uri;
	}
	public static String getParentPath(String path)
	{
		//System.out.println("getParentPath:" + path);
		String result = path;
		if(result.equals("/"))
			return result;
		if(result.endsWith("/"))
			result = result.substring(0, result.length() - 1);
		result = result.substring(0, result.lastIndexOf("/") + 1);
		//System.out.println("result:" + result);
		return result;
	}
	//public static String getLocalInfoPath(String relpath) {
	//	return relpath.replace('/', '~');
	//}
	public static String getLocalInfoPath(String localDataRoot, String relativePath) {
		return localDataRoot + ".LS-INFO/" + relativePath.replace('/', '~');
	}
	public static String getLocalPath(String localDataRoot, String relativePath) {
		if(localDataRoot.endsWith("/") && relativePath.startsWith("/"))
			relativePath = relativePath.substring(1, relativePath.length());
		return localDataRoot + relativePath;
	}
	public static String getFilePath(String relativePath, String filename) {
		if(!relativePath.endsWith("/"))
			return relativePath + "/" + filename;
		return relativePath + filename;
	}

}
